package com.vogue.sms.controller;

import java.util.Arrays;
import java.util.Map;

import com.vogue.sms.common.validator.ValidatorUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.vogue.sms.entity.ApiUserEquipmentEntity;
import com.vogue.sms.service.ApiUserEquipmentService;
import com.vogue.sms.common.utils.PageUtils;
import com.vogue.sms.common.utils.R;



/**
 * 用户设备
 *
 * @author George
 * @email qiaozhi_china@163.com
 * @date 2018-12-03 01:54:50
 */
@RestController
@RequestMapping("/api/equipment")
public class ApiUserEquipmentController {
    @Autowired
    private ApiUserEquipmentService ApiuserEquipmentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = ApiuserEquipmentService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
        ApiUserEquipmentEntity ApiuserEquipment = ApiuserEquipmentService.selectById(id);

        return R.ok().put("ApiuserEquipment", ApiuserEquipment);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody ApiUserEquipmentEntity ApiuserEquipment){
        ApiuserEquipmentService.insert(ApiuserEquipment);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody ApiUserEquipmentEntity ApiuserEquipment){
        ValidatorUtils.validateEntity(ApiuserEquipment);
        ApiuserEquipmentService.updateAllColumnById(ApiuserEquipment);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        ApiuserEquipmentService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
